SELECT UserData.*
FROM UserData
JOIN dbo.Docs AS Docs ON (UserData.[tp_RowOrdinal] = 0 AND Docs.SiteId = UserData.tp_SiteId AND 
Docs.DirName = UserData.tp_DirName  AND Docs.LeafName = UserData.tp_LeafName  AND Docs.Level = UserData.tp_Level)
WHERE tp_ListId IN ('D8EE13EA-5DA9-468F-9761-8548632DE251') AND Docs.ScopeId IN ('F6347493-6483-489A-96F7-F9B17F8637C3')

SELECT *
FROM dbo.UserData
JOIN dbo.Docs ON (UserData.[tp_RowOrdinal] = 0 AND Docs.SiteId = UserData.tp_SiteId AND 
Docs.DirName = UserData.tp_DirName  AND Docs.LeafName = UserData.tp_LeafName  AND Docs.Level = UserData.tp_Level)
WHERE tp_ListId IN ('D8EE13EA-5DA9-468F-9761-8548632DE251') AND Docs.ScopeId IN 
(
	SELECT     ScopeId
	FROM       dbo.RoleAssignment
	WHERE     PrincipalId IN 
	(
		SELECT     GroupId
		FROM       dbo.GroupMembership
		WHERE     (MemberId = 1)
	) 
	OR PrincipalId = 1
)
